package com.feicheng.house.service.impl;

import com.feicheng.house.entity.DepositClientVo;
import com.feicheng.house.entity.DepositRecordClientUserVo;
import com.feicheng.house.mapper.DepositClientVoMapper;
import com.feicheng.house.result.ResultInfo;
import com.feicheng.house.service.IDepositClientVoService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 * VIEW 服务实现类
 * </p>
 *
 * @author feichengTech
 * @since 2021-11-22
 */
@Service
public class DepositClientVoServiceImpl extends ServiceImpl<DepositClientVoMapper, DepositClientVo> implements IDepositClientVoService {

	@Override
	public ResultInfo selectAll(Integer currentPage, Integer pageSize, String searchKey, String searchState) {
		QueryWrapper<DepositClientVo> depositWrapper = new QueryWrapper<DepositClientVo>();
		if (StringUtils.hasLength(searchKey)) {
			depositWrapper.like("client_name", searchKey);						 						 	
		}
		if (StringUtils.hasLength(searchState)) {
			depositWrapper.like("deposit_state", searchState);
						 
		}
		// 创建分页查询			
		IPage< DepositClientVo> pageInfo = new Page<DepositClientVo>(currentPage, pageSize);
		return ResultInfo.success(this.page(pageInfo,depositWrapper));
	}

	@Override
	public ResultInfo getDeposit(Integer depositId) {
		QueryWrapper<DepositClientVo> depositWrapper = new QueryWrapper();
		depositWrapper.eq("deposit_id", depositId);
		
		return ResultInfo.success(this.getOne(depositWrapper));
	}

}
